<template>
    <el-header class="header">
        <el-row type="flex" align="middle" style="margin-top: 9px;">
            <el-col :span="18">
                <div>
                    <img src="/src/assets/images/logo_1.png" alt="图片">
                </div>
            </el-col>
            <el-col :span="6" style="text-align: right;color: #fff">
                <div  style="display: inline-block;" @click="dialogShow" v-if="menuList[0].url=='recycleNew'">
                    <el-badge is-dot class="item">
                        <i class="el-icon-bell"></i>
                    </el-badge>
                    <span style="margin-left: 10px;">追偿平台</span>
                </div>
                <el-popover placement="bottom" width="202" trigger="click">
                    <el-button size="mini" @click="fnDialogConfirm">
                        修改密码
                    </el-button>
                    <el-button size="mini" @click="signOut">
                        退出登录
                        <!--                    <i class="fa fa-sign-out"></i>-->
                    </el-button>
                    <el-button slot="reference" style="background: #409eff;border: navajowhite;color: white;">{{username}}
                        <i class="el-icon-arrow-down"></i>
                    </el-button>
                </el-popover>
            </el-col>
        </el-row>
    </el-header>
    <MessageList :visible.sync="dialogVisible" :registNo="registNo"></MessageList>
</template>


<script setup lang="ts">
    import MessageList from "@/components/messageList.vue";
    import {ref} from "vue"
    import { useDataStore } from '@/store/data';
    import {storeToRefs} from "pinia";
    import {logout} from "@/api";
    import {useRouter} from "vue-router";
    const dialogVisible=ref(false)
    const registNo=ref('')
    const dataStore=useDataStore();
    const {tabMenu,username,getTabMenu}=storeToRefs(dataStore)

    // const menuList=dataStore.getTabMenu.tabMenu
    const {menuList}=dataStore.tabMenu
    const router=useRouter()
    //登出
    const signOut=()=>{
        logout().then(function (response) {
            window.sessionStorage.removeItem('tokenId');
            localStorage.removeItem('username');
            // window.sensors = null
            router.push('/')
        })
    }
    //修改密码弹框
    const fnDialogConfirm=()=>{
        router.push('/resetPassword')
    }
    const dialogShow=()=>{
        dialogVisible.value=true
    }

</script>

<style scoped>

</style>
